import {
  Column,
  Entity,
  PrimaryGeneratedColumn,
  CreateDateColumn,
  UpdateDateColumn,
  ManyToOne,
  JoinColumn
} from 'typeorm';
import { BaseEntity } from 'src/common/entities/base';
import { ApiProperty } from '@nestjs/swagger';
import {ProfessionalEntity} from "../../professional/entities/professional.entity";
import {SchoolEntity} from "../../school/entities/school.entity";
import {CampusEntity} from "../../campus/entities/campus.entity";

@Entity('edu_class', {
  comment: '班级表',
})
export class ClassEntity extends BaseEntity {
  @PrimaryGeneratedColumn({ type: 'int', name: 'class_id', comment: '班级ID' })
  public classId: number;

  @ApiProperty({ description: '班级名称' })
  @Column({ type: 'varchar', name: 'class_name', length: 32, comment: '班级名称' })
  public className: string;

  @ApiProperty({ description: '入学时间' })
  @Column({ type: 'varchar', name: 'entry_date', length: 64, comment: '入学时间' })
  public entryDate: string;

  @ApiProperty({ description: '归属学校' })
  @Column({ type: 'int', name: 'school_id', comment: '归属学校' })
  public schoolId: number;

  @ApiProperty({ description: '归属校区' })
  @Column({ type: 'int', name: 'campus_id', comment: '归属校区' })
  public campusId: number;

  @ApiProperty({ description: '班主任Id' })
  @Column({ type: 'int', name: 'manager_id', comment: '班主任Id' })
  public managerId: number;


  @ApiProperty({ description: '专业ID' })
  @Column({ type: 'int', name: 'pro_id', comment: '关联专业' })
  public proId: number;


  @ManyToOne(() => ProfessionalEntity, professional => professional.proId)
  @JoinColumn({ name: 'pro_id' })
  public professional: ProfessionalEntity;

  @ManyToOne(() => SchoolEntity, school => school.schoolId)
  @JoinColumn({ name: 'school_id' })
  public school: SchoolEntity;

  @ManyToOne(() => CampusEntity, campus => campus.campusId)
  @JoinColumn({ name: 'campus_id' })
  public campus: CampusEntity;
}
